package assembler;

import java.util.HashMap;
import java.util.Map;

public class RegisterMap {
	public static final int WORD = -1;
	public static final int BYTE = -2;	
	public static final int RESW = -3;
	public static final int RESB = -4;
	public static final int notFound = -5;
	public static final int COMM = -6;
	public static final int BASE = -7;
	public static Map<String, Integer> registerTable;

	public static void setRegisterTable(){
		registerTable = new HashMap<String, Integer>();
		registerTable.put("A",  0x00);
		registerTable.put("X",  0x01);	
		registerTable.put("L",  0x02);	
		registerTable.put("B",  0x03);	
		registerTable.put("S",  0x04);	
		registerTable.put("T",  0x05);	
		registerTable.put("F",  0x06);
		registerTable.put("PC", 0x08);
		registerTable.put("SW", 0x09);
		
	}

	public static int getRegisterValue(String registerString){
		if(registerTable == null)
			setRegisterTable();
		try	{
			if(registerTable.containsKey(registerString))
				return registerTable.get(registerString);
			else
				return 0;
		}catch (NullPointerException e){
			return 0;
		}
	}
}